package com.windfone.web;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.windfone.common.WebVariable;

/**
 * Servlet implementation class InitServlet
 */
public class InitServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public InitServlet() {
        super();
    }

	/**
	 * @see Servlet#init(ServletConfig)
	 */
	public void init(ServletConfig config) throws ServletException {
		String path = config.getServletContext().getRealPath("/");
		path = path.replace("\\", "/");
		WebVariable.setWEB_ROOT_PATH(path);
		ApplicationContext springCtx=WebApplicationContextUtils.getWebApplicationContext( config.getServletContext() );
		WebVariable.setSpringCtx(springCtx);
	}

}
